package com.RMP
{
    import flash.display.*;
    import flash.events.*;
    import flash.text.*;
    import com.greensock.*;

    public class JobsThumbnail extends MovieClip
    {
        public var myXMLList:XML;
        public var objName:String = "ShortText";
        var fadeSpeed:Number;
        var applyField:BigFieldNarrow;
        public var dbId:Object;
        public var idNum:Number;
        var titleField:BigFieldNarrow;
        public var btn:Sprite;
        var myLabel:String;
        var myRoot:MovieClip;
        var bigField:BigFieldNarrow;
        var styler:StyleSheet;
        var myLongTitle:String;

        public function JobsThumbnail(param1:MovieClip, param2:Number, param3:String, param4:String, param5:int, param6:int) : void
        {
            objName = "ShortText";
            myRoot = param1;
            fadeSpeed = param2;
            myLabel = param3;
            myLongTitle = param4;
            idNum = param5;
            dbId = param6;
            buildStyles();
            buildField();
            myRoot.stage.addEventListener(Event.RESIZE, onResizer, false, 0, true);
            doResize();
            return;
        }

        function buildStyles() : void
        {
            var _loc_1:* = undefined;
            var _loc_2:* = undefined;
            var _loc_3:Object = null;
            var _loc_4:Object = null;
            var _loc_5:Object = null;
            var _loc_6:Object = null;
            var _loc_7:Object = null;
            var _loc_8:* = undefined;
            var _loc_9:Object = null;
            _loc_1 = new HelveticaLightEmbed().fontName;
            _loc_2 = new HelveticaBoldEmbed().fontName;
            styler = new StyleSheet();
            _loc_3 = new Object();
            _loc_3.color = myRoot.coldColorHTML;
            _loc_3.fontFamily = _loc_1;
            _loc_3.leading = -4;
            _loc_4 = new Object();
            _loc_4.color = myRoot.coldColorHTML;
            _loc_4.textDecoration = "underline";
            _loc_5 = new Object();
            _loc_5.color = myRoot.hotColorHTML;
            _loc_5.textDecoration = "underline";
            _loc_6 = new Object();
            _loc_6.color = myRoot.coldColorHTML;
            _loc_6.fontFamily = _loc_2;
            _loc_7 = new Object();
            _loc_7.color = myRoot.hotColorHTML;
            _loc_7.fontFamily = _loc_2;
            _loc_8 = new HelveticaItalicEmbed().fontName;
            _loc_9 = new Object();
            _loc_9.color = myRoot.coldColorHTML;
            _loc_9.fontFamily = _loc_8;
            styler.setStyle(".myItalic", _loc_9);
            styler.setStyle("p", _loc_3);
            styler.setStyle("a:link", _loc_4);
            styler.setStyle("a:hover", _loc_5);
            styler.setStyle(".mybold", _loc_6);
            return;
        }

        function doResize() : void
        {
            var _loc_1:* = myRoot.unitW / 75;
            titleField.scaleX = myRoot.unitW / 75;
            titleField.scaleY = _loc_1;
            var _loc_1:* = myRoot.unitW / 75;
            bigField.scaleX = myRoot.unitW / 75;
            bigField.scaleY = _loc_1;
            var _loc_1:* = myRoot.unitW / 75;
            applyField.scaleY = myRoot.unitW / 75;
            applyField.scaleX = _loc_1;
            bigField.y = Math.round(titleField.y + titleField.height - 3 * myRoot.unitW / 75);
            if (bigField.height > 18)
            {
                applyField.y = Math.round(bigField.y + bigField.height - 8 * myRoot.unitW / 75);
            }
            else
            {
                applyField.y = Math.round(bigField.y + bigField.height - 4 * myRoot.unitW / 75);
            }
            return;
        }

        public function jobOver() : void
        {
            TweenMax.to(titleField, fadeSpeed, {tint:16724736, overwrite:true});
            TweenMax.to(applyField, fadeSpeed, {tint:16724736, overwrite:true});
            return;
        }

        function buildField() : void
        {
            btn = new Sprite();
            btn.useHandCursor = true;
            btn.mouseEnabled = true;
            btn.buttonMode = true;
            btn.mouseChildren = false;
            titleField = new BigFieldNarrow();
            titleField.field.autoSize = "left";
            titleField.field.antiAliasType = AntiAliasType.ADVANCED;
            titleField.field.gridFitType = GridFitType.PIXEL;
            titleField.field.selectable = false;
            titleField.field.embedFonts = true;
            titleField.field.multiline = true;
            titleField.field.wordWrap = true;
            titleField.field.styleSheet = styler;
            titleField.field.htmlText = "<p><span class = \'myBold\'>" + myLabel + "</span></p>";
            titleField.field.y = -1;
            titleField.field.textColor = 7829367;
            btn.addChild(titleField);
            bigField = new BigFieldNarrow();
            bigField.field.autoSize = "left";
            bigField.field.antiAliasType = AntiAliasType.ADVANCED;
            bigField.field.gridFitType = GridFitType.PIXEL;
            bigField.field.selectable = false;
            bigField.field.embedFonts = true;
            bigField.field.multiline = true;
            bigField.field.wordWrap = true;
            bigField.field.styleSheet = styler;
            bigField.field.htmlText = "<p>" + myLongTitle + "</p>";
            bigField.field.y = -1;
            bigField.field.textColor = 7829367;
            btn.addChild(bigField);
            addChild(btn);
            applyField = new BigFieldNarrow();
            applyField.field.autoSize = "left";
            applyField.field.antiAliasType = AntiAliasType.ADVANCED;
            applyField.field.gridFitType = GridFitType.PIXEL;
            applyField.field.selectable = false;
            applyField.field.embedFonts = true;
            applyField.field.styleSheet = styler;
            applyField.field.htmlText = "<p>Apply</p>";
            applyField.field.textColor = 12500670;
            btn.addChild(applyField);
            return;
        }

        function onResizer(event:Event)
        {
            doResize();
            return;
        }

        public function jobOut() : void
        {
            TweenMax.to(titleField, fadeSpeed, {tint:7829367, overwrite:true});
            TweenMax.to(applyField, fadeSpeed, {tint:12500670, overwrite:true});
            return;
        }

        public function checkFilters(param1:String) : Boolean
        {
            var _loc_2:XMLList = null;
            _loc_2 = myXMLList.filters.id;
            if (_loc_2.contains(param1))
            {
                return true;
            }
            return false;
        }

        public function fadeInShell() : void
        {
            TweenMax.to(this, fadeSpeed, {alpha:1, overwrite:true});
            return;
        }

    }
}
